PATHMac OS 8 and 9 Developer Documentation > Human Interface Toolbox > Appearance Manager >

Programming With the Appearance Manager


Drawing Tracks

The Appearance Manager provides a variety of functions that you can use to make your program's tracks--that is, its scroll bars, sliders, and progress bars--theme-compliant. You can use the Appearance Manager to handle most aspects of drawing, obtaining values for, and checking for mouse-down events on tracks and their related parts (such as the indicator on a scroll bar or slider, a scroll bar's arrows, or the tick marks on a slider).

Your application can use the function DrawThemeTrack to draw a theme-compliant slider, progress bar, or scroll bar. If you use DrawThemeTrack to draw a scroll bar, use the function DrawThemeScrollBarArrows to draw the scroll bar's arrows; see Listing 3-7 for an example of using these two functions together to draw a complete scroll bar. If you use DrawThemeTrack to draw a slider, use DrawThemeTrackTickMarks if you need to draw tick marks for the slider.

Listing 3-7   Drawing a scroll bar with arrows

Rect bounds;
ThemeTrackDrawInfo drawInfo;
OSStatus err;

SetRect (&bounds, 10, 10, 200, 26);

/* Draw the arrows and pass the actual track rect into the
drawInfo structure for DrawThemeTrack to use */
err = DrawThemeScrollBarArrows (&bounds, kThemeTrackActive, 0, true, &drawInfo.bounds);

if (err == noErr)
{
    drawInfo.kind = kThemeScrollBar;
    /* drawInfo.bounds is set to the modified bounds, with the arrows removed,
    on exit from DrawThemeScrollBarArrows */
    drawInfo.min = 0;
    drawInfo.max = 100;
    drawInfo.value = 65;
    drawInfo.attributes = kThemeTrackHorizontal | kThemeTrackShowThumb;
    drawInfo.enableState = kThemeTrackActive;
    drawInfo.trackInfo.scrollbar.viewsize = 0;
    drawInfo.trackInfo.scrollbar.pressState = 0;

    err = DrawThemeTrack (&drawInfo, NULL, NULL, 0);
}

© 1999 Apple Computer, Inc. – (Last Updated 29 April 99)